/**
 * 
 */
package com.angel.configuration.initializer.impl;

import com.angel.architecture.persistence.beans.ConfigurationParameter;
import com.angel.common.helpers.ReflectionHelper;
import com.angel.configuration.initializer.ConfigurationInitializer;
import com.angel.webapp.application.ApplicationSearchStrategyCommands;
import com.angel.webapp.search.SearchStrategyCommand;

/**
 * @author William
 *
 */
public class SearchStrategiesInitializer extends ConfigurationInitializer{

	private static final String SEARCH_STRATEGIES_AREA_NAME = "SearchsStrategies";

	@Override
	public boolean appliesConfiguration(ConfigurationParameter cp) {
		return cp != null && cp.isForParameterArea(SEARCH_STRATEGIES_AREA_NAME);
	}

	@Override
	public void addConfiguration(ConfigurationParameter cp) {
		SearchStrategyCommand searchStrategyCommand = (SearchStrategyCommand) ReflectionHelper.createObject(cp.getStringValue());
		ApplicationSearchStrategyCommands.createInstance().addSearchStrategyCommand(cp.getName(), searchStrategyCommand);
	}
	
}
